package com.imb.provider.controller;

import com.imb.common.core.annotation.ApiLog;
import com.imb.common.core.enums.OperateEnum;
import com.imb.common.mybatis.entity.ImbLog;
import com.imb.common.web.result.JsonResult;
import com.imb.provider.service.LogService;
import com.imb.provider.vo.UserInfoVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author xzhi
 * @desc
 * @date 2024-09-27
 */
@RestController
@RequestMapping("/api/log")
@Api(tags = "日志模块")
@Slf4j(topic = "api-log")
@RequiredArgsConstructor
public class LogController {

    private final LogService logService;


    @GetMapping("/list")
    @ApiOperation(value = "操作日志")
    public JsonResult<List<ImbLog>> list() {
        return JsonResult.success(logService.lambdaQuery().orderByDesc(ImbLog::getCreateTime).list());
    }


    @GetMapping("/loginList")
    @ApiOperation(value = "登录日志")
    public JsonResult<List<ImbLog>> loginList() {
        return JsonResult.success(logService.lambdaQuery()
                .eq(ImbLog::getType,OperateEnum.LOGIN.getInfo())
                .orderByDesc(ImbLog::getCreateTime)
                .list());
    }
}
